<?php
session_start();
ob_start();
include_once dirname(dirname(__FILE__)) . '/include/common.php';
$page = isset($_POST["page"]) ? intval($_POST["page"]) : 2;
$page = $page + 1;
$core = new core();
$load_more = 0;
$list_product = $core->getListProduct($page, $load_more,25);
$html = '';

if ($list_product) {
    foreach ($list_product as $product) {

        $html.=' <tr>
            <td>'.$product->product_name.'</td>
            <td class="center">'.$product->product_code.'</td>
            <td class="center">'.$product->manufacture.'</td>
            <td class="center"><img class="photo_product" style="width: 100px;" src="photo/thumb_photo/200_'.$product->main_photo.'" rel="photo/'.$product->main_photo.'"/></td>
            <td class="center">'.$product->description.'</td>

            <td class="center">'.number_format($product->product_price/1000).'</td>
            <td class="center">';
        if ($_SESSION["user_role"] != 3) {
                $html.='<a class="btn btn-info btn_edit_category" href="addProduct.php?id='.$product->product_id.'" rel="">
                    <i class="icon-edit icon-white"></i>  
                    Edit                                            
                </a>
                <a rel="'.$product->product_id.'" class="btn btn-danger btn_delete_product" href="javascript:void(0)">
                    <i class="icon-trash icon-white"></i> 
                    Delete
                </a>';
        }
           $html.=' </td>
        </tr>';
    }
}
echo json_encode(array('type' => 0, 'html' => $html, 'page' => $page, 'load_more' => $load_more));
die;
?>